<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:ry="">
	<head>
		<th:block th:include="include :: header('字典类型列表')" />
		<th:block th:include="include :: WdatePicker-js" />
	</head>
	<body class="gray-bg">
		<div class="container-div">
			<div class="row">
				<div class="col-sm-12 search-collapse">
					<form id="type-form">
						<div class="select-list">
							<ul>
								<li>
									字典名称：<input type="text" name="dict_name"/>
								</li>
								<li>
									字典类型：<input type="text" name="dict_type"/>
								</li>
								<li>
									字典状态：<ry:selectDict dictType="sys_normal_disable" name="status" headLabel="所有" headValue=""/>
								</li>
								<li class="select-time">
									<label>创建时间： </label><input type="text" name="start_time" placeholder="开始时间" onclick="WdatePicker();" />
									<span>-</span>
									<input type="text" name="end_time" placeholder="结束时间" onclick="WdatePicker();" />
								</li>
								<li>
									<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
								</li>
							</ul>
						</div>
					</form>
				</div>

		       <div class="btn-group-sm" id="toolbar" role="group">
		            <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:dict:add">
		                <i class="fa fa-plus"></i> 新增
		            </a>
					<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:dict:remove">
			            <i class="fa fa-remove"></i> 删除
			        </a>
                    <a class="btn btn-danger" onclick="clearCache()" shiro:hasPermission="system:dict:remove">
                        <i class="fa fa-refresh"></i> 清理缓存
                    </a>
		        </div>

		        <div class="col-sm-12 select-table table-striped">
				    <table id="bootstrap-table"></table>
				</div>
			</div>
		</div>
		<th:block th:include="include :: footer" />
		<script th:inline="javascript">
			var editFlag = [[${@permission.hasPermi('system:dict:edit')}]];
			var listFlag = [[${@permission.hasPermi('system:dict:list')}]];
			var removeFlag = [[${@permission.hasPermi('system:dict:remove')}]];
			var datas = [[${@dict.getType('sys_normal_disable')}]];
			var prefix = ctx + "system/dict";

			$(function() {
			    var options = {
			        url: prefix + "/list",
			        createUrl: prefix + "/add",
			        updateUrl: prefix + "/edit/{id}",
			        removeUrl: prefix + "/remove",
			        exportUrl: prefix + "/export",
			        sortName: "dict_type",
			        sortOrder: "asc",
			        modalName: "字典组",
					pageSize: 5,
					pageList: [5, 10, 20],
			        columns: [{
			            checkbox: true
			        },
			        {
			            field: 'dict_id',
			            title: '字典主键',
			            align: "center",
			            visiable: false
			        },
			        {
			            field: 'dict_name',
			            title: '字典名称',
			            align: "center",
			            sortable: true
			        },
			        {
			            field: 'dict_type',
			            title: '字典类型',
			            sortable: true
			        },
			        {
			            field: 'status',
			            title: '状态',
			            align: 'center',
			            formatter: function(value, row, index) {
			            	return $.table.selectDictLabel(datas, value);
			            }
			        },
			        {
			            field: 'remark',
			            title: '备注',
                        formatter: function(value, row, index) {
                            return $.table.tooltip(value);
                        }
			        },
			        {
			            field: 'create_time',
			            title: '创建时间',
			            width: '150px',
			            sortable: true
			        },
			        {
			            title: '操作',
			            align: 'center',
			            width: '130px',
			            formatter: function(value, row, index) {
			                var actions = [];
			                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.dict_type + '\')"><i class="fa fa-edit"></i>编辑</a> ');
			                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.dict_id + '\')"><i class="fa fa-remove"></i>删除</a>');
			                return actions.join('');
			            }
			        }]
			    };
			    $.table.init(options);
			});

			/*字典列表-详细*/
			function detail(dict_type) {
			    var url = prefix + '/detail/' + dict_type;
			    $.modal.open("字典数据", url, 1000, 500);
			}

            /** 清理字典缓存 */
            function clearCache() {
                $.operate.get(prefix + "/clearCache");
            }
		</script>
	</body>
</html>